package com.shared.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Embedded;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Unindexed;
import com.shared.data.IData;
import com.shared.model.etat.EtatQuittance;
import com.shared.model.etat.EtatQuittanceMiseEnDemeure;
import com.shared.model.etat.EtatQuittanceNonReglee;
import com.shared.model.etat.EtatQuittanceReglee;
import com.shared.utilitaire.Date;




@Entity
public class Quittance implements IData {

	@Id private Long key;
	@Embedded private Date dateEmission ;	
	private Key<EtatQuittance> etatQuittance;
	//private String etatQuittance;
	@Embedded private Date dateChangement ;
	private double taxesAssurances ;
	private double montantCompagnie ;
	private double montantCommissions ;
	private double montantCourtage ;
	private double montantHonoraires ;
	
	
	public Quittance(){
		// TODO Auto-generated constructor stub
	}
	
	
	public Quittance(Date dEmission, Date dChangement, double t_ass, double m_comp, double m_com, double m_court,double m_hono){
		
		dateEmission = dEmission ;
		dateChangement = dChangement ;
		taxesAssurances = t_ass ;
		montantCompagnie = m_comp ;
		montantCommissions = m_com ;
		montantCourtage = m_court ;
		montantHonoraires = m_hono ;		
	}
	
	public static List<Class<? extends EtatQuittance>> getPossibleEtatClass(){
		List<Class<? extends EtatQuittance>> iterableReturn = new ArrayList<Class<? extends EtatQuittance>>();
		iterableReturn.add(EtatQuittanceNonReglee.class);
		iterableReturn.add(EtatQuittanceReglee.class);
		iterableReturn.add(EtatQuittanceMiseEnDemeure.class);
		return iterableReturn;
	}
	
	
	
	public Date getDateChangement() {
		return dateChangement;
	}
	
	public Date getDateEmission() {
		return dateEmission;
	}
	
	
	
	public double getMontantCommissions() {
		return montantCommissions;
	}
	
	public double getMontantCompagnie() {
		return montantCompagnie;
	}
	
	public double getMontantCourtage() {
		return montantCourtage;
	}
	
	public double getMontantHonoraires() {
		return montantHonoraires;
	}
	
	public double getTaxesAssurances() {
		return taxesAssurances;
	}
	

	public void setDateChangement(Date dateChangement) {
		this.dateChangement = dateChangement;
	}
	
	public void setDateEmission(Date dateEmission) {
		this.dateEmission = dateEmission;
	}
	
		
	public void setMontantCommissions(double montantCommissions) {
		this.montantCommissions = montantCommissions;
	}
	
	public void setMontantCompagnie(double montantCompagnie) {
		this.montantCompagnie = montantCompagnie;
	}
	
	public void setMontantCourtage(double montantCourtage) {
		this.montantCourtage = montantCourtage;
	}
	
	public void setMontantHonoraires(double montantHonoraires) {
		this.montantHonoraires = montantHonoraires;
	}
	
	public void setTaxesAssurances(double taxesAssurances) {
		this.taxesAssurances = taxesAssurances;
	}
	
	public double getMontantHT(){
		return (montantCompagnie - taxesAssurances + montantCommissions) ;
		
	}
	
	public double getMontantTTC(){
		return (getMontantHT() + taxesAssurances) ;
		
	}
	
	public double getMontantTotal(){
		return (getMontantTTC() + montantCourtage + montantHonoraires) ;
		
	}


	/**
	 * @param key the key to set
	 */
	public void setKey(Long key) {
		this.key = key;
	}


	/**
	 * @return the key
	 */
	public Long getKey() {
		return key;
	}


	
	/**
	 * @param etatQuittance the etatQuittance to set
	 */
	public void setEtatQuittance(Key<EtatQuittance> etatQuittance) {
		this.etatQuittance = etatQuittance;
	}
	
	


	/**
	 * @return the etatQuittance
	 */
	public Key<EtatQuittance>  getEtatQuittance() {
		return etatQuittance;
	}
}
